<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@include file="/context/mytags.jsp"%>
<div class="table-scrollable">
	<div class="order-nav">
		<a onclick="orderStatus()" style="font-size: 16px;">全部列表</a><a
			onclick="orderStatus('1')"
			style="font-size: 16px; margin-left: 10px;">待发货</a><a
			onclick="orderStatus('2')"
			style="font-size: 16px; margin-left: 10px;">已发货</a><a
			onclick="orderStatus('5')"
			style="font-size: 16px; margin-left: 10px;">已取消</a>
	</div>
	<table class="table table-striped table-hover table-info">
		<thead>
			<tr>
				<th>订单日期</th>
				<th>订单编号</th>
				<th>买家ID</th>
				<th>购买数量</th>
				<th>金额</th>
				<th>备注</th>
				<th>订单平台</th>
				<th>订单状态</th>
				<th>操作</th>

			</tr>
		</thead>
		<tbody>

			<c:forEach items="${page.result}" var="order" varStatus="vs"
				begin="${begin}" end="${end}">
				<tr>
					<td>${order.createtime }</td>
					<td><a
						onclick="add('/ordert/handOrderDetail?code=${order.code}')">${order.code }</a></td>
					<td>${order.person.uid}</td>
					<td>${order.count}</td>
					<td>${order.price}</td>
					<td>${order.description }</td>
					<td>${order.platform.name }</td>
					<td>${order.orderStatus.name }</td>
					<td><c:choose>
							<c:when test="${order.orderStatus.id==1 }">
								<a
									onclick="add('/deliverGoods/deliverGoods?orderCode=${order.code}')">手工发货</a>
							</c:when>
							<c:otherwise>
								<a onclick="toLogisticsInfo('${order.id}')">查看物流</a>
							</c:otherwise>
						</c:choose><a onclick="add('/ordert/handOrderDetail?code=${order.code}')">查看
					</a><a onclick="update('/ordert/ordert?id=${order.id}')">编辑 </a><a
						onclick="cancelOrder('${order.id}')">取消订单</a></td>
				</tr>
			</c:forEach>
		</tbody>
	</table>
</div>
<div class="pageination-panel">${page}</div>
<input id="startD" value="${startDate}" style="visibility: hidden;" />
<input id="endD" value="${endDate}" style="visibility: hidden;" />

<style type="text/css">
.order-nav {
	padding: 2% 2% 2% 0%;
}
</style>

<script type="text/javascript">
	function orderStatus(status) {

		var startDate = $("#startDate").val();
		var endDate = $("#endDate").val();

		if (startDate == "" || endDate == "") {

			startDate = $("#startD").val();
			endDate = $("#endD").val();

		}

		$.ajax({
			type : 'post',
			url : webRoot + '/ordert/list',
			data : {
				"start" : startDate,
				"end" : endDate,
				"status" : status
			},
			dataType : 'html',
			success : function(data) {
				$(".panel-content").html(data);
			}
		});
	}

	function modelShow(plateformid) {

		var startDate = $("#startDate").val();
		var endDate = $("#endDate").val();

		if (startDate == "" || endDate == "") {

			startDate = $("#startD").val();
			endDate = $("#endD").val();

		}

		var urll = webRoot + "/ordert/exportExcel?plateformid=" + plateformid
				+ "&start=" + startDate + "&end=" + endDate;

		window.open(urll);

	}

	function cancelOrder(id) {

		$.ajax({
			type : 'post',
			url : webRoot + '/ordert/ListFormsaves',
			data : {
				"id" : id,
				"orderStatusId" : 5
			},
			dataType : 'json',
			success : function(data) {
				search();
				$(".panel-search").show();
			}
		});

	}

	function toLogisticsInfo(orderid) {
		
		$.ajax({
			type : 'post',
			url : webRoot + '/webpage/shopping/Amazon/jdt.jsp',
			dataType : 'html',
			success : function(data) {
				$(".panel-content").html(data);
			}
		});


		$.ajax({
			type : 'post',
			url : webRoot + '/amazonorderslists/orderLogisticsInfo',
			data : {
				"orderid" : orderid
			},
			dataType : 'html',
			success : function(data) {
				$(".panel-search").hide();
				$(".panel-content").html(data);
			}
		});

	}

	function searchStatus(status) {

		alert(status)

	}
</script>